package com.phoenix.jsef.demo.configuration;

import com.phoenix.jsef.jdbcutils.SqlHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


@Configuration
@ConfigurationProperties("spring.datasource")
@AutoConfigureAfter(value= {DruidDataSourceConfig.class})
public class DBConnectionConfig {

	@Autowired
	@Qualifier("druidDataSource")
	private DataSource dataSource;
	
	private String dbParamterPrefix = "";
	
	public String getDbParamterPrefix() {
		return dbParamterPrefix;
	}
	public void setDbParamterPrefix(String dbParamterPrefix) {
		this.dbParamterPrefix = dbParamterPrefix;
	}
	@Bean(name="sqlHelper")
	public SqlHelper sqlHelper() {
		//JDBCUtils jdbcUtils = new JDBCUtils(dataSource,dbParamterPrefix);
		SqlHelper sqlHelper = new SqlHelper();
        sqlHelper.setDataSource(dataSource);
        sqlHelper.setDbParamterPrefix(dbParamterPrefix);
		return sqlHelper;
	}
	
}
